var marguee={
    speed:20,
    direction:"right",
    con:"msglist",
    stage:"stagemsg",
    step:1,
    intervalId:0,
    maxWidth:1000,
    conWidth:200,
    init:function(){

   marguee.maxWidth=$("."+marguee.stage).width();
   marguee.conWidth=$("."+marguee.con).width();
     if(marguee.direction=="left"){
       marguee.step=-marguee.step;
       $("."+marguee.con).css({"left": marguee.maxWidth});
     }else{
       //反转文字
        marguee.step=marguee.step;
        $("."+marguee.con).css({"left":-marguee.conWidth});
     }


     $("."+marguee.con).bind("mouseover",marguee.stop);
     $("."+marguee.con).bind("mouseout",marguee.start);
     marguee.start();
    },
    start:function(){
       marguee.intervalId=setInterval(marguee.run,marguee.speed);
    },
    run:function(){
     var left=$("."+marguee.con).position().left;

     left+=marguee.step;
     if(left<-marguee.conWidth&&marguee.direction=="left"){
       $("."+marguee.con).css({"left":marguee.maxWidth});
       return;
     }
     if(left>marguee.maxWidth&&marguee.direction=="right"){
       $("."+marguee.con).css({"left":-marguee.conWidth});
       return;
     }

     $("."+marguee.con).css({"left":left});

    },
    reverse:function(str){
	  	tmp = "" + str;
	  	result = "";
	  	for(i = tmp.length;i >= 0;i-=1){
			  result += tmp.substring(i,i+1);
   		}
	  	return result;
   	},
    stop:function(){
      clearInterval(marguee.intervalId);
    }




}
